#include<bits/stdc++.h>
using namespace std;
int n,L,R;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&L,&R);
	if(R-L>=n)printf("%d",n-1);
	else if(L%n+R-L>=n-1)printf("%d",n-1);
	else printf("%d",L%n+R-L);
	return 0;
}
